'use strict';

const Controller = require('egg').Controller;

class TestDBMysql extends Controller{
    async addMysql(){
        const {ctx} = this;
        const res = await ctx.service.testMysqlEgg.addMysql({id:5,name:'小白',sex:'boy',sikll:'打架'})
        ctx.body ='添加' + JSON.stringify(res)
    }
    async delMysql(){
        const {ctx} = this;
        const res = await ctx.service.testMysqlEgg.delMysql({id:5})
        ctx.body ='删除'  + JSON.stringify(res) 
    }
    async editorMysql(){
        const {ctx} = this;
        const res = await ctx.service.testMysqlEgg.editorMysql({id:5,name:'小牛',sex:'boy',sikll:'打架笑'})
        if (res){
           
            ctx.body ='修改成功'  + JSON.stringify(res)
        }else{
            ctx.body = '修改失败-'
        }
    }
    async showMysql(){
        const {ctx} = this;
        const res = await ctx.service.testMysqlEgg.showMysql();
        ctx.body ='查看' +JSON.stringify(res)
    }
}

module.exports = TestDBMysql